from django.db import models
from xiaoshuo.utils.models import BaseModel
# Create your models here.
class Book_cate(models.Model):
    name=models.CharField(max_length=20,verbose_name='书籍分类名字')

class Books(BaseModel):
    USER_METHODS_ENUM={
        'UNPAID':0,
        'UNSEND':1
    }
    USER_METHOD_CHOICES={
        (0,'普通书籍'),
        (1,'vip书籍')
    }

    name=models.CharField(max_length=20,verbose_name='书名',unique=True)
    img=models.CharField(max_length=1000,verbose_name='封面')
    author=models.CharField(max_length=20,verbose_name='作者')
    synopsis=models.CharField(max_length=200,verbose_name='简介')
    count_read=models.IntegerField(default=0,verbose_name='阅读量')
    bookrack_count=models.IntegerField(default=0,verbose_name='加入书架次数')
    is_vip=models.SmallIntegerField(choices=USER_METHOD_CHOICES,default=0,verbose_name='书籍状态')
    cate=models.ForeignKey(Book_cate,on_delete=models.CASCADE,verbose_name='关联分类')


class Chapter(BaseModel):
    name=models.CharField(max_length=200,verbose_name='章节名')
    books=models.ForeignKey(Books,on_delete=models.CASCADE,verbose_name='关联书籍')

class Content(models.Model):
    text=models.CharField(max_length=2000,verbose_name='内容')
    chapter=models.ForeignKey(Chapter,on_delete=models.CASCADE,verbose_name='关联章节表')





